//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace OpenLS.Spreadsheet.UI
{



    sealed class PreviewAdorner : Adorner
    {
        // Fields
        private Decorator _decorator;
        private TranslateTransform Translation;

        // Methods
        public PreviewAdorner(FrameworkElement gridSplitter, Style previewStyle)
            : base(gridSplitter)
        {
            Control control = new Control();
            control.Style = previewStyle;
            control.IsEnabled = false;
            control.Background = Brushes.Yellow;
            control.SetValue(Grid.RowProperty, 0);
            control.SetValue(Grid.RowSpanProperty, 3);
            this.Translation = new TranslateTransform();
            this._decorator = new Decorator();
            this._decorator.Child = control;
            this._decorator.RenderTransform = this.Translation;
            base.AddVisualChild(this._decorator);
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            this._decorator.Arrange(new Rect(new Point(), finalSize));
            return finalSize;
        }

        protected override Visual GetVisualChild(int index)
        {
            if (index != 0)
            {
                throw new ArgumentException();
            }
            return this._decorator;
        }

        // Properties
        public double OffsetX
        {
            get
            {
                return this.Translation.X;
            }
            set
            {
                this.Translation.X = value;
            }
        }

        public double OffsetY
        {
            get
            {
                return this.Translation.Y;
            }
            set
            {
                this.Translation.Y = value;
            }
        }

        protected override int VisualChildrenCount
        {
            get
            {
                return 1;
            }
        }
    }


}
